package com.shopnight.service.impl;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shopnight.dto.AddTakeoutOrdersDto;
import com.shopnight.entity.TakeoutMerchantCart;
import com.shopnight.entity.TakeoutOrders;
import com.shopnight.interceptors.JWTInterceptor;
import com.shopnight.service.TakeoutOrdersService;
import com.shopnight.mapper.TakeoutOrdersMapper;
import com.shopnight.utils.UserContext;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 13201
* @description 针对表【takeout_orders(外卖订单表)】的数据库操作Service实现
* @createDate 2023-03-23 20:35:13
*/
@Service
public class TakeoutOrdersServiceImpl extends ServiceImpl<TakeoutOrdersMapper, TakeoutOrders>
    implements TakeoutOrdersService{

    @Override
    public List<TakeoutMerchantCart> addTakeoutOrders(AddTakeoutOrdersDto addTakeoutOrdersDto) {
        //设置用户的id
        String userId =  UserContext.getEndUserId();

        TakeoutOrders takeoutOrders = new TakeoutOrders();
        BeanUtils.copyProperties(addTakeoutOrdersDto,takeoutOrders);
        takeoutOrders.setCode(String.valueOf(IdWorker.getId()));
        takeoutOrders.setStatus(1);
        takeoutOrders.setUserId(Integer.valueOf(userId));



        return null;
    }
}




